<?php
namespace EasyVote\EasyVoteBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use EasyVote\EasyVoteBundle\Entity\DegreeType;

/**
 * Class LoadDegreeTypeData
 * Loads degree types in the database
 * @package EasyVote\EasyVoteBundle\DataFixtures\ORM
 */
class LoadDegreeTypeData extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        //Create all degree types, including B.S, M.S, Ph.D, etc.
        $bs = new DegreeType();
        $bs->setName('BS');
        $bs->setDescription('Bachelor of Science');
        $manager->persist($bs);
        $manager->flush();

        $ba = new DegreeType();
        $ba->setName('BA');
        $ba->setDescription('Bachelor of Arts');
        $manager->persist($ba);
        $manager->flush();

        $ma = new DegreeType();
        $ma->setName('MA');
        $ma->setDescription('Master of Arts');
        $manager->persist($ma);
        $manager->flush();

        $ms = new DegreeType();
        $ms->setName('MS');
        $ms->setDescription('Master of Science');
        $manager->persist($ms);
        $manager->flush();

        $phd = new DegreeType();
        $phd->setName('PhD');
        $phd->setDescription('Doctor of Philosophy');
        $manager->persist($phd);
        $manager->flush();
    }

    /**
     * {@inheritDoc}
     */
    public function getOrder()
    {
        return 6; // the order in which fixtures will be loaded
    }
}

?>
